package com.bigbirdmed.cloud.common.core.page;


import com.bigbirdmed.cloud.common.core.util.Utilities;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @author Toomth
 * @date 2021/4/12 18:27
 * @explain
 */
public class PaginationInput {
	@Data
	@ApiModel(value = "PageDTO", description = "列表分页参数")
	public static class PageDTO implements Serializable {

		private static final long serialVersionUID = 1L;

		/** 默认起始页码 */
		private static final Integer DEFAULT_PAGE_NUM = 1;
		/** 默认分页大小 */
		private static final Integer DEFAULT_PAGE_SIZE = 20;

		@ApiModelProperty(value = "页码")
		private Integer pageNum;

		@ApiModelProperty(value = "每页数据")
		private Integer pageSize;

		@ApiModelProperty(value = "排序（false:倒序 true:正序）")
		private Boolean sort = false;

		@ApiModelProperty(value = "排序字段名")
		private String orderByColumn;

		public Integer getPageNum() {
			if(!Utilities.isValidId(pageNum)){
				this.pageNum = DEFAULT_PAGE_NUM;
			}
			return pageNum;
		}

		public Integer getPageSize() {
			if(!Utilities.isValidId(pageSize)){
				this.pageSize = DEFAULT_PAGE_SIZE;
			}
			return pageSize;
		}
	}

	@Data
	@EqualsAndHashCode(callSuper = true)
	@ApiModel(value = "PageDTO", description = "单查询模糊分页请求")
	public static class AdminPageDto extends PageDTO implements Serializable {

		private static final long serialVersionUID = 1L;

		@ApiModelProperty(value = "搜索条件值")
		private String searchText;


	}


}
